package com.dynamixsoftware.printershare.snmp;

import java.io.ByteArrayOutputStream;
import java.util.Enumeration;
import java.util.Vector;

public class SNMPSequence
  extends SNMPObject
{
  protected Vector<Object> sequence;
  protected byte tag = 48;
  
  public SNMPSequence()
  {
    this.sequence = new Vector();
  }
  
  public SNMPSequence(Vector<Object> paramVector)
    throws SNMPBadValueException
  {
    Enumeration localEnumeration = paramVector.elements();
    while (localEnumeration.hasMoreElements()) {
      if (!(localEnumeration.nextElement() instanceof SNMPObject)) {
        throw new SNMPBadValueException("Non-SNMPObject supplied to SNMPSequence.");
      }
    }
    this.sequence = paramVector;
  }
  
  protected SNMPSequence(byte[] paramArrayOfByte)
    throws SNMPBadValueException
  {
    extractFromBEREncoding(paramArrayOfByte);
  }
  
  private byte[] encodeVector()
  {
    ByteArrayOutputStream localByteArrayOutputStream = new ByteArrayOutputStream();
    int i = this.sequence.size();
    for (int j = 0; j < i; j++)
    {
      byte[] arrayOfByte = ((SNMPObject)this.sequence.elementAt(j)).getBEREncoding();
      localByteArrayOutputStream.write(arrayOfByte, 0, arrayOfByte.length);
    }
    return localByteArrayOutputStream.toByteArray();
  }
  
  public void addSNMPObject(SNMPObject paramSNMPObject)
    throws SNMPBadValueException
  {
    this.sequence.insertElementAt(paramSNMPObject, this.sequence.size());
  }
  
  protected void extractFromBEREncoding(byte[] paramArrayOfByte)
    throws SNMPBadValueException
  {
    Vector localVector = new Vector();
    int i = paramArrayOfByte.length;
    int j = 0;
    while (j < i)
    {
      SNMPTLV localSNMPTLV = SNMPBERCodec.extractNextTLV(paramArrayOfByte, j);
      localVector.insertElementAt(SNMPBERCodec.extractEncoding(localSNMPTLV), localVector.size());
      j += localSNMPTLV.totalLength;
    }
    this.sequence = localVector;
  }
  
  public byte[] getBEREncoding()
  {
    ByteArrayOutputStream localByteArrayOutputStream = new ByteArrayOutputStream();
    byte[] arrayOfByte1 = encodeVector();
    byte[] arrayOfByte2 = SNMPBERCodec.encodeLength(arrayOfByte1.length);
    localByteArrayOutputStream.write(this.tag);
    localByteArrayOutputStream.write(arrayOfByte2, 0, arrayOfByte2.length);
    localByteArrayOutputStream.write(arrayOfByte1, 0, arrayOfByte1.length);
    return localByteArrayOutputStream.toByteArray();
  }
  
  public SNMPObject getSNMPObjectAt(int paramInt)
  {
    return (SNMPObject)this.sequence.elementAt(paramInt);
  }
  
  public Object getValue()
  {
    return this.sequence;
  }
  
  public void insertSNMPObjectAt(SNMPObject paramSNMPObject, int paramInt)
    throws SNMPBadValueException
  {
    this.sequence.insertElementAt(paramSNMPObject, paramInt);
  }
  
  public void setValue(Object paramObject)
    throws SNMPBadValueException
  {
    if ((paramObject instanceof Vector))
    {
      Enumeration localEnumeration = ((Vector)paramObject).elements();
      while (localEnumeration.hasMoreElements()) {
        if (!(localEnumeration.nextElement() instanceof SNMPObject)) {
          throw new SNMPBadValueException("Non-SNMPObject supplied to SNMPSequence.");
        }
      }
      this.sequence = ((Vector)paramObject);
      return;
    }
    throw new SNMPBadValueException(" Sequence: bad object supplied to set value ");
  }
  
  public int size()
  {
    return this.sequence.size();
  }
  
  public String toString()
  {
    StringBuffer localStringBuffer = new StringBuffer("(");
    for (int i = 0; i < this.sequence.size(); i++)
    {
      localStringBuffer.append(" ");
      localStringBuffer.append(((SNMPObject)this.sequence.elementAt(i)).toString());
      localStringBuffer.append(" ");
    }
    localStringBuffer.append(")");
    return localStringBuffer.toString();
  }
}


/* Location:           C:\Users\Admin\Desktop\Decompiler\JAD\jd-gui-0.3.6.windows\classes_dex2jar.jar
 * Qualified Name:     com.dynamixsoftware.printershare.snmp.SNMPSequence
 * JD-Core Version:    0.7.0.1
 */